﻿#ifndef DRAWINFO_H
#define DRAWINFO_H

#include <QObject>
#include <QTransform>

class DrawParam : public QObject
{
    Q_OBJECT
public:
    explicit DrawParam(QObject *parent = nullptr);


    void initTransform(QRect rc);
    void initWindow(double wl, double ww);
    void applyTransform();
    void reset();
    void addTranslate(int dx, int dy);
    void addScale(double ds);
    void adjustWindow(double dx, double dy);
    void addAngle(double a);
    void addFlip(int type);
    void rotate(double a);

    const QTransform &getTransform() const;
    void setTransform(const QTransform &newTransform);
    const QTransform &getImgTrans() const;
    int getFrame() const;
    void setFrame(int newFrame);
    int getWidth() const;
    void setSize(int newWidth, int newHeight);
    int getHeight() const;
    double getDefWW() const;
    double getDefWL() const;
    void setDefWindow(double newDefWL, double newDefWW);
    double getCurWW() const;
    double getCurWL() const;
    void setCurWindow(double newCurWL, double newCurWW);
    double getZoom() const;
    void setZoom(double newZoom);
    double getAngle() const;
    void setAngle(double newAngle);
    int getAdjustType() const;
    void setAdjustType(int newAdjustType);
    bool getNegative() const;
    void setNegative(bool newNegative);
    bool getCornerText() const;
    void setCornerText(bool newCornerText);


signals:

    void transformChanged();
    void frameChanged();
    void sizeChanged();
    void defWindowChanged();
    void curWindowChanged();
    void zoomChanged();
    void angleChanged();
    void adjustTypeChanged();
    void negativeChanged();
    void cornerTextChanged();

private:
    QTransform transform;
    QTransform imgTrans;
    int frame = 0;
    int width = 0;
    int height = 0;
    double defWW = 0.0;
    double defWL = 0.0;
    double curWW = 0.0;
    double curWL = 0.0;
    double zoom = 1.0;
    double angle = 0.0;
    int flip = 0;  // 0 无翻转, 1 水平翻转, 2 垂直翻转, 3 水平+垂直翻转
    int offsetX = 0;
    int offsetY = 0;

    bool negative = false;
    QRect rect;


};

#endif // DRAWINFO_H
